#!/bin/sh

mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs udev /dev
mkdir /dev/pts
mount -n -t devpts -o gid=5,mode=620 none /dev/pts
udevd --daemon
udevadm trigger
udevadm settle
chmod a+rx /

ETH0=`awk 'BEGIN {RS = " "} ; {split($1,a,"="); if (a[1] == "eth0") {print a[2]; }}' /proc/cmdline`
ETH1=`awk 'BEGIN {RS = " "} ; {split($1,a,"="); if (a[1] == "eth1") {print a[2]; }}' /proc/cmdline`
ifconfig lo up
ifconfig eth0 up $ETH0 netmask 255.255.255.0
ifconfig eth1 up $ETH1 netmask 255.255.255.0

mkdir /var/run/sshd
/usr/sbin/sshd

# nat
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# end nat

setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'
